home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / PCSETVEC.C < prev    next >
Text File  |  1990-08-09  |  1KB  |  54 lines

  1. /**
  2. *
  3. *  Name         pcsetvec -- Set interrupt vector
  4. *
  5. *  Synopsis     ercode = pcsetvec(intype,pvector);
  6. *               int ercode        Error return code
  7. *               int intype        Interrupt type number
  8. *               ADS *pvector      Address (CS:IP) of the interrupt
  9. *                                 service routine or address type.
  10. *
  11. *  Description  This function sets the interrupt type to the address
  12. *               specified in pvector.
  13. *
  14. *  Returns      ercode            If intype is not in the range 0 to 255
  15. *                                 1 is returned; otherwise 0.
  16. *
  17. *  Version      1.1  (C)Copyright Blaise Computing Inc.  1983, 1984
  18. *
  19. **/
  20. #define utbyword(a,b)   (((a)<<8)|((b)&0x00ff))  /* a is high, b low   */
  21. #define utoutrng(a,l,h) (((a)<(l)||(a)>(h))?1:0) /* Is a out of range? */
  22.  
  23. struct segads                          /* Offset, segment address type */
  24. {
  25.   unsigned r;
  26.   unsigned s;
  27. };
  28. #define ADS     struct segads          /* Abbreviation                 */
  29.  
  30. struct dreg
  31. {
  32.   unsigned ax,bx,cx,dx,si,di,ds,es;
  33. };
  34. #define DOSREG  struct dreg
  35.  
  36. int pcsetvec(intype,pvector)
  37. int intype;
  38. ADS *pvector;
  39. {
  40.  
  41.     DOSREG dos_reg;
  42.  
  43.     if (utoutrng(intype,0,255))
  44.        return(1);
  45.     utinit(&dos_reg);                  /* Initialize registers         */
  46.     dos_reg.ax = utbyword(0x25,intype);
  47.     dos_reg.ds = pvector->s;
  48.     dos_reg.dx = pvector->r;
  49.     dos(&dos_reg);
  50.  
  51.     return(0);
  52.  
  53. }
  54.